#tcp server test

from socket import * 
from time import ctime,sleep
import sys
import os
def main():
    port = 40087
    hort = ''
    buffsize = 1024
    addr = (hort,port)
    tcpSocketSvr = socket(AF_INET,SOCK_STREAM)
    tcpSocketSvr.bind(addr)
    tcpSocketSvr.listen(3)
    while 1:
        sleep(1)
        tcpClient,addr = tcpSocketSvr.accept()
        print ("Collect from :",addr)
        while 1:
            data = tcpClient.recv(buffsize)
            if(data is None):
                pass
            tcpClient.send("data is %s,time is %s"%(data,ctime()))
        tcpClient.close()
    tcpSocketSvr.close()
if __name__ == "__main__":
    main()
